<template>
    <div style="padding: 10px">
        <Row :gutter="2">
            <Col :span="12">
                <Card :dis-hover="true" :bordered="false">
                    <iview-table
                            ref="table"
                            :span1="16"
                            :span2="8"
                            :baseURL="queryModel.baseURL"
                            :menuId="dataModel.menuId"
                            :columns="dataModel.columns"
                            :order="dataModel.order"
                            :pageNumber="pageModel.pageNumber"
                            :pageSize="pageModel.pageSize"
                            :defaultFilters="queryModel.defaultFilters"
                            v-on="{changeTotalSize:changeTotalSize,changeSelect:changeSelect}">
                    </iview-table>
                    <br>
                    <iview-page
                            :totalSize="pageModel.totalSize"
                            :pageNumber="pageModel.pageNumber"
                            :pageSize="pageModel.pageSize"
                            :pageSizeOpts="pageModel.pageSizeOpts"
                            v-on="{changePageNumber:changePageNumber,changePageSize:changePageSize}">
                    </iview-page>
                </Card>
            </Col>
            <Col :span="12">
                <Card :dis-hover="true" :bordered="false">

                </Card>
            </Col>
        </Row>
    </div>
</template>

<script>
    import iviewTable from '@/view/common/table/Table.vue';
    import iviewPage from '@/view/common/page/Page.vue';
    export default {
        components: {
            iviewTable,
            iviewPage
        },
        data () {
            return {
                selectRows: [],
                baseURL: '/user/treat/plan/home',
                queryModel: {
                    // 网关代理路径(必须)+资源路径(可选)
                    baseURL: '/user/treat/plan/home',
                    defaultFilters: [
                        {'field': 'complaint_id', 'value1': '-1', 'operate': '=='}
                    ]
                },
                dataModel: {
                    menuId: 650,
                    columns: [
                        {
                            type: 'selection',
                            width: 60,
                            align: 'center'
                        },
                        {
                            title: '病房名称',
                            key: 'homeName',
                            className: 'demo-table-info-column'
                        },
                        {
                            title: '治疗周期',
                            key: 'treatCycle',
                            className: 'demo-table-info-column',
                            render: (h, params) => {
                                let temp = params.row.treatCycle
                                if (temp === 0) {
                                    temp = '不限时间'
                                } else {
                                    temp += '年'
                                }
                                return temp
                            }
                        },
                        {
                            title: '添加时间',
                            key: 'creationTime',
                            className: 'demo-table-info-column',
                            render: (h, params) => {
                                return this.$moment(params.row.creationTime).format('YYYY年MM月DD日')
                            }
                        },
                        {
                            title: '收费状态',
                            key: 'chargeStatus',
                            className: 'demo-table-info-column',
                            render: (h, params) => {
                                let temp = params.row.chargeStatus
                                if (temp === 0) {
                                    return h('div', [
                                        h('Tag', {
                                            props: {
                                                type: 'border',
                                                color: 'yellow'
                                            },
                                            style: {
                                            }
                                        }, '待交费')
                                    ]);
                                } else if (temp === 1) {
                                    return h('div', [
                                        h('Tag', {
                                            props: {
                                                type: 'border',
                                                color: 'green'
                                            },
                                            style: {
                                            }
                                        }, '已交费')
                                    ]);
                                }
                            }
                        }
                    ],
                    order: 'id desc'
                },
                pageModel: {
                    totalSize: 0,
                    pageNumber: 1,
                    pageSize: 10,
                    pageSizeOpts: [5, 10, 20, 50, 100]
                }
            };
        },
        methods: {
            refresh () {
                this.queryModel.defaultFilters[0] = {'field': 'complaint_id', 'value1': this.$store.state.app.complaintId, 'operate': '=='}
                this.$refs.table.refresh()
            },
            changeSelect (rows) {
                this.selectRows = rows
            },
            changeTotalSize (totalSize) {
                this.pageModel.totalSize = totalSize
            },
            changePageNumber (pageNumber) {
                this.pageModel.pageNumber = pageNumber
            },
            changePageSize (pageSize) {
                this.pageModel.pageSize = pageSize
            }
        },
        beforeRouteEnter (to, from, next) {
            next(vm => {
                vm.init()
            })
        }
    }
</script>

<style>
    .sag {
        width: 100%;
        height: 1000px;
        border-radius: 4px;
        /*border:1px solid #333;*/
        box-shadow:inset 0 0 5px 5px #ccc;
        padding: 10px;
    }
</style>
